package me.yricky.cov_spectrum.ui.content

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

fun String.pangoLineageNext(pangoLineage:String):Boolean = equals(pangoLineage) || startsWith("$pangoLineage.")

@Composable
fun VOCBadge(modifier: Modifier = Modifier,fullName:String){
    Box(modifier){
        when{
            fullName.pangoLineageNext("B.1.1.7") -> Text(
                text = "Alpha",
                fontSize = 12.sp,
                modifier = Modifier
                    .background(Color(0x33996666), RoundedCornerShape(2.dp))
                    .padding(2.dp)
            )
            fullName.pangoLineageNext("B.1.351") -> Text(
                text = "Beta",
                fontSize = 12.sp,
                modifier = Modifier
                    .background(Color(0x33339999), RoundedCornerShape(2.dp))
                    .padding(2.dp)
            )
            fullName.pangoLineageNext("B.1.617.2") -> Text(
                text = "Delta",
                fontSize = 12.sp,
                modifier = Modifier
                    .background(Color(0x33cc3333), RoundedCornerShape(2.dp))
                    .padding(2.dp)
            )
            fullName.pangoLineageNext("B.1.1.529") -> Text(
                text = "Omicron",
                fontSize = 12.sp,
                modifier = Modifier
                    .background(Color(0x33993399), RoundedCornerShape(2.dp))
                    .padding(2.dp)
            )
        }
    }
}